#include "ReadScores.h"
#include "TextDrawer.h"

using namespace std;

ReadScores::ReadScores(){
	//just initialize nothing


}

void ReadScores::draw(int x, int y)
{
	char chars;
	string combo;
	vector <string> comboList;

	string fileName = "scores.txt";
	ifstream fin(fileName.c_str());

	while (fin >> combo){
		comboList.push_back(combo.c_str());
	}

	fin.close();

	TextDrawer text;
	
	text.drawHighScoreNames("Can you beat:", -50, 44, -699);

	for (vector<int>::size_type i = 0; i != comboList.size(); ++i){

		int size =  (int)(comboList[i].size());
		float padding = -(((size / 2.0f) - 1.5f) * 10.0f);

		if (i == 0)
			text.drawHighScoreNames("1st", -30.0f + padding, (-i * 14) + 30, -699);
		else if (i == 1)
			text.drawHighScoreNames("2nd", -30.0f + padding, (-i * 14) + 30, -699);
		else
			text.drawHighScoreNames("3rd", -30.0f + padding, (-i * 14) + 30, -699);

		text.drawHighScoreNames(comboList[i], 10.0f + padding, (-i * 14) + 30, -699);
	}


	/*int j = 0;
	for (vector<int>::size_type i = 0; i != comboList.size(); ++i){

		if (i%2 == 0)
			text.drawHighScoreNames(comboList[i], -50 + (j*50), (-i * 10) + 50, -699);
		else
			text.drawHighScoreNames(comboList[i], -50 + (j*50), ((-i + 1) * 10) + 50, -699);

		j++;
		
		if (j == 2)
			j = 0;
	}*/
	

}